﻿namespace QMVnSoft
{
    using QMVnSoft.Properties;
    using QMVnSoft.SystemForms;
    using QMVnSoft.DAL;
    using System;
    using System.Data;
    using System.Drawing;
    using System.Globalization;
    using System.IO;
    using System.Management;
    using System.Net;
    using System.Windows.Forms;
    using QMVnSoft.DAL.Util;    

    public static class AppInstance
    {
        private static bool ib_AlcoholCtrl;
        private static bool ib_BarcodeReader;
        private static bool ib_ChangedInvoice;
        private static bool ib_CheckTrialVersion = false;
        private static bool ib_CostingInvoice;
        private static bool ib_DampCtrl;
        private static bool ib_DeadLineCtrl;
        private static bool ib_FilterByUser;
        private static bool ib_HistoryCtrl;
        private static bool ib_ItemFilter;
        private static bool ib_LocationCtrl;
        private static bool ib_LockAfterPrint;
        private static bool ib_LockDefault;
        private static bool ib_LotNumberCtrl;
        private static bool ib_ObjectFilter;
        private static bool ib_ParentCompany;
        private static bool ib_PostDefault;
        private static bool ib_QualityCtrl;
        private static bool ib_UserValiated = false;
        private static bool ib_VATInPrice;
        private static DateTime id_EndingDateOfSubEnterprice = DateTime.Now;
        private static DateTime id_EndWorkingDate = DateTime.Today;
        private static DateTime id_OpeningDateOfSubEnterprice = DateTime.Now;
        private static DateTime id_StartWorkingDate = DateTime.Today;
        private static decimal ii_AmountRange;
        private static int ii_Bilingual;
        private static int ii_CostingMethod;
        private static int ii_DaysBackup;
        private static int ii_DaysFilter;
        private static int ii_DebitWarning;
        private static int ii_DefaultKey;
        private static int ii_DefLanguage;
        private static decimal ii_DiscountRange;
        private static int ii_DiscountType;
        private static int ii_ExchangeFormat;
        private static int ii_ExchangeRate;
        private static int ii_FCAmountDecimals;
        private static int ii_FCPriceDecimals;
        private static float ii_FontSize;
        private static int ii_KeySaveAs;
        private static int ii_LCAmountDecimals;
        private static int ii_LCPriceDecimals;
        private static int ii_NormQuantity;
        private static int ii_NumberDigits;
        private static int ii_PercentDecimals;
        private static int ii_QuantityDecimals;
        private static int ii_RatioFormat;
        private static int ii_ShowDateTime;
        private static int ii_StockWarning;
        private static int ii_UnCompMethod;
        private static int ii_UserType = 0;
        private static decimal ii_VATRange;
        private static int ii_WorkingYear;
        private static string is_Account1331;
        private static string is_Account33311;
        private static string is_Account33312;
        private static string is_Account3332;
        private static string is_Account33331;
        private static string is_Account33332;
        private static string is_Account5156;
        private static string is_Account521;
        private static string is_Account6356;
        private static string is_AddressOfEnterprise = "Hà Nội";
        private static string is_AddressOfSubEnterprice = "";
        private static string is_BankAccount = "";
        private static string is_BankCapital = "";
        private static string is_BankName = "";
        private static string is_BankOwner = "";
        private static string is_Currencies;
        private static string is_DefaultCode1;
        private static string is_DefaultCode2;
        private static string is_DefaultCode3;
        private static string is_DefaultCurrency;
        private static string is_DefaultSubsidiary;
        private static string is_DeleMessage;
        private static string is_EndMessage;
        private static string is_FirstRowReport;
        private static string is_FontName;
        private static string is_FullName;
        private static string is_InitMessage;
        private static string is_NameOfEnterprise = "Công ty cổ phần ...";
        private static string is_NameOfSubEnterprice = "";
        private static string is_NotValidChars;
        private static string is_Password;
        private static string is_PaymentMethod;
        private static string is_ProcessCode;
        private static string is_ProcMessage;
        private static string is_SecondRowReport;
        private static string is_SoftwareName = "Phần mềm kế toán doanh nghiệp";
        private static string is_Subsidiaries;
        private static string is_Subsidiary = "GS01";
        private static string is_TaxCodeOfSubEnterprice = "";
        private static string is_ThirdRowReport;
        private static string is_UserName;
        private static string is_Licensed;
        private static FormCalculator oCalculator;

        public static string RemoteVersion
        {
            get
            {
                AutoUpdateService.AutoUpdateService service = new AutoUpdateService.AutoUpdateService();
                service.Url = string.Format("http://{0}/Sample/AutoUpdateService.asmx", QMVnSoft.Properties.Settings.Default.localhost);
                return service.GetRemoteVersion();
            }
        }

        public static bool CheckServer()
        {
            if ((!(ServerName == ".") && !(ServerName.ToUpper() == ".\\SQLEXPRESS") && !(ServerName.ToUpper() == "LOCALHOST") && !(ServerName.ToUpper() == "(LOCAL)")) && (!(ServerName.ToUpper() == Dns.GetHostName().ToUpper()) && !(ServerName == GetIP())))
            {
                return false;
            }
            return true;
        }
        

        public static void CompanyRegister()
        {
            DataTable table = AppDataAccess.CheckTrueVer();
            if (table != null)
            {
                UserDataAccess access = new UserDataAccess();
                string str = AppSecurity.Base64Decode((string) table.Rows[0]["SoftwareSerialKey"]);
                string str2 = str.Substring(00, 4);
                string str3 = str.Substring(05, 4);
                string str4 = str.Substring(10, 4);
                string str5 = str.Substring(15, 4);
                string str6 = str.Substring(20, 4);
                if (!AppSecurity.SoftwareDecode(0x8b, str2, str3, str4, str5, str6))
                {
                    NameOfEnterprise = "Công Ty Cổ Phần Tin Học Quang Minh - Demo";
                    AddressOfEnterprise = "Số 7 Tây Sơn - Yết Kiêu - Hà Đông - Hà Nội";
                    CheckTrialVersion = true;
                }
                else
                {
                    NameOfEnterprise = AppSecurity.Base64Decode((string) table.Rows[0][(DefLanguage == 0) ? "LocalName" : "EnglishName"]);
                    AddressOfEnterprise = AppSecurity.Base64Decode((string) table.Rows[0][(DefLanguage == 0) ? "LocalAddress" : "EnglishAddress"]);
                    CheckTrialVersion = false;
                }
            }
            else
            {
                NameOfEnterprise = "Công Ty Cổ Phần Tin Học Quang Minh - Demo";
                AddressOfEnterprise = "Số 7 Tây Sơn - Yết Kiêu - Hà Đông - Hà Nội";
                CheckTrialVersion = true;
            }
        }

        public static bool CompanyRegister(string ps_Code)
        {
            bool flag = false;
            bool flag2 = false;
            bool flag3 = false;
            string str = "";
            string str2 = "";
            string str3 = "";
            string str4 = "";
            string str5 = "";
            string str6 = "";
            string str7 = "";
            DateTime today = DateTime.Today;
            DateTime time2 = DateTime.Today;
            CompanyDataAccess access = new CompanyDataAccess();
            access.CompanyRegister(DefLanguage, ps_Code, ref flag, ref flag2, ref flag3, ref str, ref str2, ref str3, ref str4, ref str5, ref str6, ref str7, ref today, ref time2);
            if (!flag)
            {
                return false;
            }
            ParentCompany = flag3;
            Subsidiary = ps_Code;
            if (flag2)
            {
                NameOfSubEnterprice = str;
                AddressOfEnterprise = str2;
            }
            TaxCodeOfSubEnterprice = str3;
            BankAccount = str4;
            BankOwner = str5;
            BankName = str6;
            BankCapital = str7;
            OpeningDateOfSubEnterprice = today;
            EndingDateOfSubEnterprice = time2;
            if (ParentCompany)
            {
                Subsidiaries = access.GetSubsidiaries(UserName);
            }
            else
            {
                Subsidiaries = "," + Subsidiary + ",";
            }
            return true;
        }

        public static void GetConnectionString()
        {
            AppDataAccess.ConnectionString = "Server=" + ServerName + ";Database=" + DatabaseName + ";User ID=" + ServerUserName + ";Password=" + ServerPassword + ";Connection Reset=FALSE;Min Pool Size=2;Connection Lifetime=120;Connection Timeout=60;";
        }

        public static string GetProductID()
        {
            string serial = string.Empty;
            try
            {
                serial = string.Format("{0}{1}{2}", SystemInfo.GetCPUId(), SystemInfo.GetHDDSerialNumber("C"), SystemInfo.GetMainBoardSerialNumber());
                serial = serial.Replace(".", "");
                serial = serial.Replace("-", "");
                serial = serial.Replace("\\", "");
                serial = serial.Replace("/", "");
                serial = serial.Replace("//", "");
                serial = AppSecurity.Base64Encode(serial);
            }
            catch
            {
            }
            return serial;
        }

        private static string GetIP()
        {
            IPAddress[] addressList = Dns.GetHostEntry(Dns.GetHostName()).AddressList;
            return addressList[addressList.Length - 1].ToString();
        }

        public static void InitSysMem()
        {
            ii_DefLanguage = short.Parse(AppDataAccess.GetUservar(UserName, "m.English").ToString());
            is_FontName = AppDataAccess.GetMemvar(1, "M_Font").ToString();
            ii_FontSize = long.Parse(AppDataAccess.GetMemvar(1, "M_FntSize").ToString());
            ii_DefaultKey = short.Parse(AppDataAccess.GetMemvar(1, "M_Def_Key").ToString());
            ii_KeySaveAs = short.Parse(AppDataAccess.GetMemvar(1, "M_KeySaveAs").ToString());
            is_NotValidChars = AppDataAccess.GetMemvar(1, "M_Chr_Err").ToString();
            is_Currencies = AppDataAccess.GetMemvar(1, "M_Dm_TteList").ToString();
            is_DefaultCurrency = AppDataAccess.GetMemvar(1, "M_Ma_Tte0").ToString();
            ii_CostingMethod = short.Parse(AppDataAccess.GetMemvar(1, "M_PP_Gia").ToString());
            ii_UnCompMethod = short.Parse(AppDataAccess.GetMemvar(1, "M_PP_DDSP").ToString());
            ii_DaysBackup = short.Parse(AppDataAccess.GetMemvar(1, "M_Auto_Backup").ToString());
            ib_ChangedInvoice = short.Parse(AppDataAccess.GetMemvar(1, "M_Change_Voucher").ToString()) == 1;
            ib_CostingInvoice = short.Parse(AppDataAccess.GetMemvar(1, "M_Cost_Voucher").ToString()) == 1;
            ib_AlcoholCtrl = short.Parse(AppDataAccess.GetMemvar(1, "M_Ctrl_Alcohol_Degree").ToString()) == 1;
            ib_DampCtrl = short.Parse(AppDataAccess.GetMemvar(1, "M_Ctrl_Damp_Degree").ToString()) == 1;
            ib_DeadLineCtrl = short.Parse(AppDataAccess.GetMemvar(1, "M_Ctrl_DeadLine").ToString()) == 1;
            ib_LotNumberCtrl = short.Parse(AppDataAccess.GetMemvar(1, "M_Ctrl_Lot_No").ToString()) == 1;
            ib_LocationCtrl = short.Parse(AppDataAccess.GetMemvar(1, "M_Ctrl_Location").ToString()) == 1;
            ib_QualityCtrl = short.Parse(AppDataAccess.GetMemvar(1, "M_Ctrl_Quality_Item").ToString()) == 1;
            ii_DebitWarning = short.Parse(AppDataAccess.GetMemvar(1, "M_Cust_Warning").ToString());
            ii_StockWarning = short.Parse(AppDataAccess.GetMemvar(1, "M_Item_Warning").ToString());
            ii_ExchangeRate = short.Parse(AppDataAccess.GetMemvar(1, "M_Exchange_Rate").ToString());
            ii_ShowDateTime = short.Parse(AppDataAccess.GetMemvar(1, "M_Show_DateTime").ToString());
            is_InitMessage = AppDataAccess.GetMemvar(1, "M_IniVar").ToString();
            is_ProcMessage = AppDataAccess.GetMemvar(1, "M_Process").ToString();
            is_EndMessage = AppDataAccess.GetMemvar(1, "M_End_Proc").ToString();
            is_DeleMessage = AppDataAccess.GetMemvar(1, "M_SureDele").ToString();
            is_FirstRowReport = AppDataAccess.GetMemvar(1, "M_First_Row_D").ToString();
            is_SecondRowReport = AppDataAccess.GetMemvar(1, "M_Second_Row_D").ToString();
            is_ThirdRowReport = AppDataAccess.GetMemvar(1, "M_Third_Row_D").ToString();
            is_Account1331 = AppDataAccess.GetMemvar(1, "M_Tk1331").ToString();
            is_Account33311 = AppDataAccess.GetMemvar(1, "M_Tk33311").ToString();
            is_Account33312 = AppDataAccess.GetMemvar(1, "M_Tk33312").ToString();
            is_Account3332 = AppDataAccess.GetMemvar(1, "M_Tk3332").ToString();
            is_Account33331 = AppDataAccess.GetMemvar(1, "M_Tk33331").ToString();
            is_Account33332 = AppDataAccess.GetMemvar(1, "M_Tk33332").ToString();
            is_Account5156 = AppDataAccess.GetMemvar(1, "M_Tk5156").ToString();
            is_Account521 = AppDataAccess.GetMemvar(1, "M_Tk521").ToString();
            is_Account6356 = AppDataAccess.GetMemvar(1, "M_Tk6356").ToString();
            ii_LCPriceDecimals = short.Parse(AppDataAccess.GetMemvar(1, "LCPriceDecimals").ToString());
            ii_FCPriceDecimals = short.Parse(AppDataAccess.GetMemvar(1, "FCPriceDecimals").ToString());
            ii_LCAmountDecimals = short.Parse(AppDataAccess.GetMemvar(1, "LCAmountDecimals").ToString());
            ii_FCAmountDecimals = short.Parse(AppDataAccess.GetMemvar(1, "FCAmountDecimals").ToString());
            ii_PercentDecimals = short.Parse(AppDataAccess.GetMemvar(1, "PercentDecimals").ToString());
            ii_ExchangeFormat = short.Parse(AppDataAccess.GetMemvar(1, "ExchangeFormat").ToString());
            ii_NumberDigits = short.Parse(AppDataAccess.GetMemvar(1, "NumberDigits").ToString());
            ii_AmountRange = long.Parse(AppDataAccess.GetMemvar(1, "M_Tron_Tien").ToString());
            ii_VATRange = long.Parse(AppDataAccess.GetMemvar(1, "M_Tron_VAT").ToString());
            ii_DiscountRange = long.Parse(AppDataAccess.GetMemvar(1, "M_Tron_Chiet_Khau").ToString());
            ib_VATInPrice = short.Parse(AppDataAccess.GetMemvar(1, "M_Gia_Thue_Default").ToString()) == 1;
            ii_DiscountType = short.Parse(AppDataAccess.GetMemvar(1, "M_Loai_Ck_Default").ToString());
            ib_LockAfterPrint = short.Parse(AppDataAccess.GetMemvar(1, "M_Lock_After_Print").ToString()) == 1;
            ib_LockDefault = short.Parse(AppDataAccess.GetMemvar(1, "M_Locked_Default").ToString()) == 1;
            ib_PostDefault = short.Parse(AppDataAccess.GetMemvar(1, "M_Status_Default").ToString()) == 1;
            ib_HistoryCtrl = short.Parse(AppDataAccess.GetMemvar(1, "M_Vou_History").ToString()) == 1;
            ii_Bilingual = short.Parse(AppDataAccess.GetMemvar(1, "M_Voucher_EV").ToString());
        }

        public static void InitUserMem()
        {
            ii_QuantityDecimals = short.Parse(AppDataAccess.GetUservar(UserName, "QuantityDecimals").ToString());
            ii_NormQuantity = short.Parse(AppDataAccess.GetUservar(UserName, "NormQuantity").ToString());
            ii_RatioFormat = short.Parse(AppDataAccess.GetUservar(UserName, "RatioFormat").ToString());
            ib_FilterByUser = short.Parse(AppDataAccess.GetUservar(UserName, "FilterByUser").ToString()) == 1;
            ib_ItemFilter = short.Parse(AppDataAccess.GetUservar(UserName, "Lookup_Vt").ToString()) == 1;
            ib_ObjectFilter = short.Parse(AppDataAccess.GetUservar(UserName, "Lookup_Dt").ToString()) == 1;
            ib_BarcodeReader = short.Parse(AppDataAccess.GetUservar(UserName, "Ma_Vach_BarCode").ToString()) == 1;
            is_DefaultSubsidiary = AppDataAccess.GetUservar(UserName, "Ma_Dvcs_Default").ToString();
            is_PaymentMethod = AppDataAccess.GetUservar(UserName, "Payment_Method").ToString();
            is_ProcessCode = AppDataAccess.GetUservar(UserName, "Ma_Sp_Default").ToString();
            is_DefaultCode1 = AppDataAccess.GetUservar(UserName, "Ma_Loai1_Default").ToString();
            is_DefaultCode2 = AppDataAccess.GetUservar(UserName, "Ma_Loai2_Default").ToString();
            is_DefaultCode3 = AppDataAccess.GetUservar(UserName, "Ma_Loai3_Default").ToString();
            ii_DaysFilter = short.Parse(AppDataAccess.GetUservar(UserName, "Ngay_Loc_Ct").ToString());
        }

        private static string NumberConvert(object pi_Number, int pi_TotalDigits, int pi_DecimalDigits)
        {
            string str = ((decimal) pi_Number).ToString();
            string numberDecimalSeparator = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
            string str3 = "";
            string str4 = "";
            int num = 0;
            if (str.Contains(numberDecimalSeparator))
            {
                str3 = str.Substring(0, str.IndexOf(numberDecimalSeparator));
                str4 = str.Substring(str.IndexOf(numberDecimalSeparator) + 1, pi_DecimalDigits);
                num = (pi_DecimalDigits < 2) ? ((pi_TotalDigits - str3.Length) - 3) : (((pi_TotalDigits - str3.Length) - pi_DecimalDigits) - 1);
                for (int k = 0; k < num; k++)
                {
                    str3 = str3.Insert(0, "0");
                }
                if (pi_DecimalDigits < 2)
                {
                    num = 2 - pi_DecimalDigits;
                    for (int m = 0; m < num; m++)
                    {
                        str4 = str4.Insert(str4.Length, "0");
                    }
                }
                return (str3 + numberDecimalSeparator + str4);
            }
            str3 = str;
            num = (pi_DecimalDigits < 2) ? ((pi_TotalDigits - str3.Length) - 3) : (((pi_TotalDigits - str3.Length) - pi_DecimalDigits) - 1);
            for (int i = 0; i < num; i++)
            {
                str3 = str3.Insert(0, "0");
            }
            num = (pi_DecimalDigits < 2) ? 2 : pi_DecimalDigits;
            for (int j = 0; j < num; j++)
            {
                str4 = str4 + "0";
            }
            return (str3 + numberDecimalSeparator + str4);
        }

        public static string NumToWordEN(object pi_Number, object ps_Currency, int pi_DecimalDigits)
        {
            string str = "";
            int num = 5;
            if (pi_Number.Equals(DBNull.Value) || (((decimal) pi_Number) == 0M))
            {
                str = "Zero only";
            }
            else
            {
                string str2 = "billion million thousand";
                string str3 = "one  two  threefour five six  seveneightnine";
                string str4 = "twenty thirty fourty fifty  sixty  seventyeighty ninety]";
                string str5 = " ";
                string numberDecimalSeparator = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
                string str7 = NumberConvert(pi_Number, num * 3, pi_DecimalDigits);
                for (int i = 0; i < num; i++)
                {
                    string str8 = str7.Substring(i * 3, 3);
                    string str9 = "";
                    string str10 = "";
                    if (!string.Empty.Equals(str8.Trim()))
                    {
                        if (str8 == "000")
                        {
                            if (i == (num - 2))
                            {
                                str9 = (string) ps_Currency;
                            }
                        }
                        else
                        {
                            string s = str8.Substring(0, 1);
                            string str12 = str8.Substring(1, 1);
                            string str13 = str8.Substring(2, 1);
                            string str14 = str8.Substring(1, 2);
                            string str15 = "";
                            if ((s != numberDecimalSeparator) && (short.Parse(s) > 0))
                            {
                                str15 = str3.Substring((short.Parse(s) - 1) * 5, 5).Trim();
                            }
                            string str16 = "";
                            if (short.Parse(str12) > 1)
                            {
                                str16 = str4.Substring((short.Parse(str12) - 2) * 7, 7).Trim() + str5;
                            }
                            string str17 = "";
                            if (str14 == "10")
                            {
                                str17 = "ten ";
                            }
                            else if (str14 == "11")
                            {
                                str17 = "eleven ";
                            }
                            else if (str14 == "12")
                            {
                                str17 = "twelve ";
                            }
                            else if (str14 == "13")
                            {
                                str17 = "thirteen ";
                            }
                            else if (str14 == "15")
                            {
                                str17 = "fifteen ";
                            }
                            else if (str12 == "1")
                            {
                                if (short.Parse(str13) > 0)
                                {
                                    str17 = str3.Substring((short.Parse(str13) - 1) * 5, 5).Trim() + "teen ";
                                }
                            }
                            else if (short.Parse(str13) > 0)
                            {
                                str17 = str3.Substring((short.Parse(str13) - 1) * 5, 5).Trim();
                            }
                            str15 = str15 + (string.Empty.Equals(str15) ? "" : ((str14 == "00") ? "hundred " : "hundred and "));
                            if (str8 == (numberDecimalSeparator + "00"))
                            {
                                str10 = str10.TrimEnd(new char[0]) + str5 + ((string) ps_Currency) + str5 + "only";
                            }
                            else if (str8.Contains(numberDecimalSeparator))
                            {
                                str9 = "cent";
                                str10 = str10.TrimEnd(new char[0]) + str5 + ((string) ps_Currency) + str5 + "and" + str5 + str16 + str17 + str9;
                            }
                            else
                            {
                                str9 = str5 + str2.Substring(i * 8, 8).Trim();
                                str10 = str10.TrimEnd(new char[0]) + (string.Empty.Equals(str10) ? ((i != 0) ? ", " : " ") : "") + str15 + str16 + str17 + str9;
                            }
                        }
                    }
                    str = str + str9;
                }
            }
            str = str.Trim();
            return (str.Substring(0, 1).ToUpper() + str.Substring(1) + ".");
        }

        public static string NumToWordVN(object pi_Number, object ps_Currency, int pi_DecimalDigits)
        {
            string str = "";
            string str2 = "";
            int num = 5;
            if (pi_Number.Equals(DBNull.Value) || (((decimal) pi_Number) == 0M))
            {
                str = "không đồng";
            }
            else
            {
                string str3 = "trăm mươi tỷ   trăm mươi triệutrăm mươi nghìn trăm mươi đồng trăm mươi xu   ";
                string str4 = "một hai ba  bốn năm sáu bảy tám chín";
                string str5 = " ";
                string numberDecimalSeparator = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator;
                if (((decimal) pi_Number) < 0M)
                {
                    str2 = "trừ ";
                    pi_Number = ((decimal) pi_Number) * -1M;
                }
                string str7 = NumberConvert(pi_Number, num * 3, pi_DecimalDigits);
                for (int i = 0; i < num; i++)
                {
                    string str8 = str7.Substring(i * 3, 3);
                    string str9 = "";
                    if (!string.Empty.Equals(str8.Trim()))
                    {
                        if (str8 == "000")
                        {
                            if (i == 3)
                            {
                                str9 = "đồng ";
                            }
                        }
                        else if (str8 == (numberDecimalSeparator + "00"))
                        {
                            str9 = "chẵn";
                        }
                        else
                        {
                            string str10 = str8.Substring(0, 1);
                            string str11 = str8.Substring(1, 1);
                            string str12 = str8.Substring(2, 1);
                            for (int j = 0; j < 3; j++)
                            {
                                string str13 = "";
                                int num4 = 0;
                                if (!str8.Substring(j, 1).Contains(numberDecimalSeparator))
                                {
                                    num4 = short.Parse(str8.Substring(j, 1));
                                }
                                if (num4 > 0)
                                {
                                    str13 = str4.Substring((num4 - 1) * 4, 4).Trim() + str5 + str3.Substring((i * 15) + (j * 5), 5).Trim() + str5;
                                }
                                if ((j == 1) && (num4 == 1))
                                {
                                    str13 = "mười ";
                                }
                                else if (((j == 2) && (num4 == 0)) && (str8 != "  0"))
                                {
                                    str13 = str3.Substring((i * 15) + (j * 5), 5).Trim() + str5;
                                }
                                else if (((j == 2) && (num4 == 5)) && !" 0".Contains(str11))
                                {
                                    str13 = "l" + str13.Substring(1);
                                }
                                else if (((j == 2) && (num4 == 1)) && (str11 == "1"))
                                {
                                    str13 = "một " + str13.Substring(4);
                                }
                                else if (((j == 2) && (num4 == 1)) && !" 0".Contains(str11))
                                {
                                    str13 = "mốt " + str13.Substring(4);
                                }
                                else if (((j == 1) && (num4 == 0)) && ((str12 != "0") && !string.Empty.Equals(str + str9)))
                                {
                                    if ("123456789".Contains(str10) || (str10 == "0"))
                                    {
                                        str13 = "lẻ ";
                                    }
                                }
                                else if (((j == 0) && (num4 == 0)) && !string.Empty.Equals(str + str9))
                                {
                                    str13 = "không" + str5 + str3.Substring((i * 15) + (j * 5), 5).Trim() + str5;
                                }
                                str9 = str9 + str13;
                            }
                        }
                        str = str + str9;
                    }
                }
            }
            str = (str2 + str).Trim();
            if (((string) ps_Currency) != "VND")
            {
                str.Replace("đồng", (string) ps_Currency);
            }
            return (str.Substring(0, 1).ToUpper() + str.Substring(1) + ".");
        }

        public static void OnSave()
        {
            Instance.Save();
        }        

        public static bool TaxCodeValidate(object ps_TaxCode)
        {
            if (ps_TaxCode.Equals(DBNull.Value) || string.Empty.Equals(ps_TaxCode.ToString()))
            {
                return true;
            }
            if ((((string) ps_TaxCode).Length != 10) && (((string) ps_TaxCode).Length != 13))
            {
                return false;
            }
            char[] chArray = ((string) ps_TaxCode).ToCharArray();
            for (int i = 0; i < chArray.Length; i++)
            {
                if (!char.IsDigit(chArray[i]))
                {
                    return false;
                }
            }
            int num2 = 0;
            int num3 = short.Parse(chArray[9].ToString());
            num2 += short.Parse(chArray[0].ToString()) * 0x1f;
            num2 += short.Parse(chArray[1].ToString()) * 0x1d;
            num2 += short.Parse(chArray[2].ToString()) * 0x17;
            num2 += short.Parse(chArray[3].ToString()) * 0x13;
            num2 += short.Parse(chArray[4].ToString()) * 0x11;
            num2 += short.Parse(chArray[5].ToString()) * 13;
            num2 += short.Parse(chArray[6].ToString()) * 7;
            num2 += short.Parse(chArray[7].ToString()) * 5;
            num2 += short.Parse(chArray[8].ToString()) * 3;
            num2 -= (num2 / 11) * 11;
            return ((10 - num2) == num3);
        }

        public static string Account1331
        {
            get
            {
                return is_Account1331;
            }
            set
            {
                if (is_Account1331 != value)
                {
                    is_Account1331 = value;
                    AppDataAccess.SetMemvar("M_Tk1331", is_Account1331);
                }
            }
        }

        public static string Account33311
        {
            get
            {
                return is_Account33311;
            }
            set
            {
                if (is_Account33311 != value)
                {
                    is_Account33311 = value;
                    AppDataAccess.SetMemvar("M_Tk33311", is_Account33311);
                }
            }
        }

        public static string Account33312
        {
            get
            {
                return is_Account33312;
            }
            set
            {
                if (is_Account33312 != value)
                {
                    is_Account33312 = value;
                    AppDataAccess.SetMemvar("M_Tk33312", is_Account33312);
                }
            }
        }

        public static string Account3332
        {
            get
            {
                return is_Account3332;
            }
            set
            {
                if (is_Account3332 != value)
                {
                    is_Account3332 = value;
                    AppDataAccess.SetMemvar("M_Tk3332", is_Account3332);
                }
            }
        }

        public static string Account33331
        {
            get
            {
                return is_Account33331;
            }
            set
            {
                if (is_Account33331 != value)
                {
                    is_Account33331 = value;
                    AppDataAccess.SetMemvar("M_Tk33331", is_Account33331);
                }
            }
        }

        public static string Account33332
        {
            get
            {
                return is_Account33332;
            }
            set
            {
                if (is_Account33332 != value)
                {
                    is_Account33332 = value;
                    AppDataAccess.SetMemvar("M_Tk33332", is_Account33332);
                }
            }
        }

        public static string Account5156
        {
            get
            {
                return is_Account5156;
            }
            set
            {
                if (is_Account5156 != value)
                {
                    is_Account5156 = value;
                    AppDataAccess.SetMemvar("M_Tk5156", is_Account5156);
                }
            }
        }

        public static string Account521
        {
            get
            {
                return is_Account521;
            }
            set
            {
                if (is_Account521 != value)
                {
                    is_Account521 = value;
                    AppDataAccess.SetMemvar("M_Tk521", is_Account521);
                }
            }
        }

        public static string Account6356
        {
            get
            {
                return is_Account6356;
            }
            set
            {
                if (is_Account6356 != value)
                {
                    is_Account6356 = value;
                    AppDataAccess.SetMemvar("M_Tk6356", is_Account6356);
                }
            }
        }

        public static string AddressOfEnterprise
        {
            get
            {
                return is_AddressOfEnterprise;
            }
            set
            {
                is_AddressOfEnterprise = value;
            }
        }

        public static string AddressOfSubEnterprice
        {
            get
            {
                return is_AddressOfSubEnterprice;
            }
            set
            {
                is_AddressOfSubEnterprice = value;
            }
        }

        public static bool AlcoholCtrl
        {
            get
            {
                return ib_AlcoholCtrl;
            }
            set
            {
                if (ib_AlcoholCtrl != value)
                {
                    ib_AlcoholCtrl = value;
                    AppDataAccess.SetMemvar("M_Ctrl_Alcohol_Degree", ib_AlcoholCtrl ? "1" : "0");
                }
            }
        }

        public static decimal AmountRange
        {
            get
            {
                return ii_AmountRange;
            }
            set
            {
                if (ii_AmountRange != value)
                {
                    ii_AmountRange = value;
                    AppDataAccess.SetMemvar("M_Tron_Tien", ii_AmountRange.ToString());
                }
            }
        }

        public static string BankAccount
        {
            get
            {
                return is_BankAccount;
            }
            set
            {
                is_BankAccount = value;
            }
        }

        public static string BankCapital
        {
            get
            {
                return is_BankCapital;
            }
            set
            {
                is_BankCapital = value;
            }
        }

        public static string BankName
        {
            get
            {
                return is_BankName;
            }
            set
            {
                is_BankName = value;
            }
        }

        public static string BankOwner
        {
            get
            {
                return is_BankOwner;
            }
            set
            {
                is_BankOwner = value;
            }
        }

        public static bool BarcodeReader
        {
            get
            {
                return ib_BarcodeReader;
            }
            set
            {
                if (ib_BarcodeReader != value)
                {
                    ib_BarcodeReader = value;
                    AppDataAccess.SetUservar(UserName, "Ma_Vach_BarCode", ib_BarcodeReader ? "1" : "0");
                }
            }
        }

        public static int Bilingual
        {
            get
            {
                return ii_Bilingual;
            }
            set
            {
                if (ii_Bilingual != value)
                {
                    ii_Bilingual = value;
                    AppDataAccess.SetMemvar("M_Voucher_EV", ii_Bilingual.ToString());
                }
            }
        }

        public static int CalculatorLeftPosition
        {
            get
            {
                return Instance.CalculatorLeftPosition;
            }
            set
            {
                Instance.CalculatorLeftPosition = value;
            }
        }

        public static int CalculatorTopPosition
        {
            get
            {
                return Instance.CalculatorTopPosition;
            }
            set
            {
                Instance.CalculatorTopPosition = value;
            }
        }

        public static bool ChangedInvoice
        {
            get
            {
                return ib_ChangedInvoice;
            }
            set
            {
                if (ib_ChangedInvoice != value)
                {
                    ib_ChangedInvoice = value;
                    AppDataAccess.SetMemvar("M_Change_Voucher", ib_ChangedInvoice ? "1" : "0");
                }
            }
        }

        public static bool CheckTrialVersion
        {
            get
            {
                return ib_CheckTrialVersion;
            }
            set
            {
                ib_CheckTrialVersion = value;
            }
        }

        public static string AppVersion
        {
            get
            {
                return AppDataAccess.Version;
            }            
        }

        public static bool CostingInvoice
        {
            get
            {
                return ib_CostingInvoice;
            }
            set
            {
                if (ib_CostingInvoice != value)
                {
                    ib_CostingInvoice = value;
                    AppDataAccess.SetMemvar("M_Cost_Voucher", ib_CostingInvoice ? "1" : "0");
                }
            }
        }

        public static int CostingMethod
        {
            get
            {
                return ii_CostingMethod;
            }
            set
            {
                if (ii_CostingMethod != value)
                {
                    ii_CostingMethod = value;
                    AppDataAccess.SetMemvar("M_PP_Gia", ii_CostingMethod.ToString());
                }
            }
        }

        public static string Currencies
        {
            get
            {
                return is_Currencies;
            }
            set
            {
                if (is_Currencies != value)
                {
                    is_Currencies = value;
                    AppDataAccess.SetMemvar("M_Dm_TteList", is_Currencies);
                }
            }
        }

        public static bool DampCtrl
        {
            get
            {
                return ib_DampCtrl;
            }
            set
            {
                if (ib_DampCtrl != value)
                {
                    ib_DampCtrl = value;
                    AppDataAccess.SetMemvar("M_Ctrl_Damp_Degree", ib_DampCtrl ? "1" : "0");
                }
            }
        }

        public static string DatabaseBackupPath
        {
            get
            {
                return Instance.DatabaseBackupPath;
            }
            set
            {
                Instance.DatabaseBackupPath = value;
            }
        }

        public static string DatabaseName
        {
            get
            {
                return Instance.DatabaseName;
            }
            set
            {
                Instance.DatabaseName = value;
            }
        }

        public static int DaysBackup
        {
            get
            {
                return ii_DaysBackup;
            }
            set
            {
                if (ii_DaysBackup != value)
                {
                    ii_DaysBackup = value;
                    AppDataAccess.SetMemvar("M_Auto_Backup", ii_DaysBackup.ToString());
                }
            }
        }

        public static int DaysFilter
        {
            get
            {
                return ii_DaysFilter;
            }
            set
            {
                if (ii_DaysFilter != value)
                {
                    ii_DaysFilter = value;
                    AppDataAccess.SetUservar(UserName, "Ngay_Loc_Ct", ii_DaysFilter.ToString());
                }
            }
        }

        public static bool DeadLineCtrl
        {
            get
            {
                return ib_DeadLineCtrl;
            }
            set
            {
                if (ib_DeadLineCtrl != value)
                {
                    ib_DeadLineCtrl = value;
                    AppDataAccess.SetMemvar("M_Ctrl_DeadLine", ib_DeadLineCtrl ? "1" : "0");
                }
            }
        }

        public static int DebitWarning
        {
            get
            {
                return ii_DebitWarning;
            }
            set
            {
                if (ii_DebitWarning != value)
                {
                    ii_DebitWarning = value;
                    AppDataAccess.SetMemvar("M_Cust_Warning", ii_DebitWarning.ToString());
                }
            }
        }

        public static string DefaultCode1
        {
            get
            {
                return is_DefaultCode1;
            }
            set
            {
                if (is_DefaultCode1 != value)
                {
                    is_DefaultCode1 = value;
                    AppDataAccess.SetUservar(UserName, "Ma_Loai1_Default", is_DefaultCode1);
                }
            }
        }

        public static string DefaultCode2
        {
            get
            {
                return is_DefaultCode2;
            }
            set
            {
                if (is_DefaultCode2 != value)
                {
                    is_DefaultCode2 = value;
                    AppDataAccess.SetUservar(UserName, "Ma_Loai2_Default", is_DefaultCode2);
                }
            }
        }

        public static string DefaultCode3
        {
            get
            {
                return is_DefaultCode3;
            }
            set
            {
                if (is_DefaultCode3 != value)
                {
                    is_DefaultCode3 = value;
                    AppDataAccess.SetUservar(UserName, "Ma_Loai3_Default", is_DefaultCode3);
                }
            }
        }

        public static string DefaultCurrency
        {
            get
            {
                return is_DefaultCurrency;
            }
            set
            {
                if (is_DefaultCurrency != value)
                {
                    is_DefaultCurrency = value;
                    AppDataAccess.SetMemvar("M_Ma_Tte0", is_DefaultCurrency);
                }
            }
        }

        public static int DefaultKey
        {
            get
            {
                return ii_DefaultKey;
            }
            set
            {
                if (ii_DefaultKey != value)
                {
                    ii_DefaultKey = value;
                    AppDataAccess.SetMemvar("M_Def_Key", ii_DefaultKey.ToString());
                }
            }
        }

        public static string DefaultSubsidiary
        {
            get
            {
                return is_DefaultSubsidiary;
            }
            set
            {
                if (is_DefaultSubsidiary != value)
                {
                    is_DefaultSubsidiary = value;
                    AppDataAccess.SetUservar(UserName, "Ma_Dvcs_Default", is_DefaultSubsidiary);
                }
            }
        }

        public static int DefLanguage
        {
            get
            {
                return ii_DefLanguage;
            }
            set
            {
                if (ii_DefLanguage != value)
                {
                    ii_DefLanguage = value;
                    AppDataAccess.SetUservar(UserName, "m.English", ii_DefLanguage.ToString());
                    CompanyRegister();
                }
            }
        }

        public static string DeleMessage
        {
            get
            {
                return is_DeleMessage;
            }
            set
            {
                if (is_DeleMessage != value)
                {
                    is_DeleMessage = value;
                    AppDataAccess.SetMemvar("M_SureDele", is_DeleMessage);
                }
            }
        }

        public static string DEMOString
        {
            get
            {
                if (!CheckTrialVersion)
                {
                    return "";
                }
                return "QUANG MINH";
            }
        }

        public static decimal DiscountRange
        {
            get
            {
                return ii_DiscountRange;
            }
            set
            {
                if (ii_DiscountRange != value)
                {
                    ii_DiscountRange = value;
                    AppDataAccess.SetMemvar("M_Tron_Chiet_Khau", ii_DiscountRange.ToString());
                }
            }
        }

        public static int DiscountType
        {
            get
            {
                return ii_DiscountType;
            }
            set
            {
                if (ii_DiscountType != value)
                {
                    ii_DiscountType = value;
                    AppDataAccess.SetMemvar("M_Loai_Ck_Default", ii_DiscountType.ToString());
                }
            }
        }

        public static DateTime EndingDateOfSubEnterprice
        {
            get
            {
                return id_EndingDateOfSubEnterprice;
            }
            set
            {
                id_EndingDateOfSubEnterprice = value;
            }
        }

        public static string EndMessage
        {
            get
            {
                return is_EndMessage;
            }
            set
            {
                if (is_EndMessage != value)
                {
                    is_EndMessage = value;
                    AppDataAccess.SetMemvar("M_End_Proc", is_EndMessage);
                }
            }
        }

        public static DateTime EndWorkingDate
        {
            get
            {
                return id_EndWorkingDate;
            }
            set
            {
                id_EndWorkingDate = value;
            }
        }

        public static int ExchangeFormat
        {
            get
            {
                return ii_ExchangeFormat;
            }
            set
            {
                if (ii_ExchangeFormat != value)
                {
                    ii_ExchangeFormat = value;
                    AppDataAccess.SetMemvar("ExchangeFormat", ii_ExchangeFormat.ToString());
                }
            }
        }

        public static int ExchangeRate
        {
            get
            {
                return ii_ExchangeRate;
            }
            set
            {
                if (ii_ExchangeRate != value)
                {
                    ii_ExchangeRate = value;
                    AppDataAccess.SetMemvar("M_Exchange_Rate", ii_ExchangeRate.ToString());
                }
            }
        }

        public static int FCAmountDecimals
        {
            get
            {
                return ii_FCAmountDecimals;
            }
            set
            {
                if (ii_FCAmountDecimals != value)
                {
                    ii_FCAmountDecimals = value;
                    AppDataAccess.SetMemvar("FCAmountDecimals", ii_FCAmountDecimals.ToString());
                }
            }
        }

        public static int FCPriceDecimals
        {
            get
            {
                return ii_FCPriceDecimals;
            }
            set
            {
                if (ii_FCPriceDecimals != value)
                {
                    ii_FCPriceDecimals = value;
                    AppDataAccess.SetMemvar("FCPriceDecimals", ii_FCPriceDecimals.ToString());
                }
            }
        }

        public static bool FilterByUser
        {
            get
            {
                return ib_FilterByUser;
            }
            set
            {
                if (ib_FilterByUser != value)
                {
                    ib_FilterByUser = value;
                    AppDataAccess.SetUservar(UserName, "FilterByUser", ib_FilterByUser ? "1" : "0");
                }
            }
        }

        public static string FirstRowReport
        {
            get
            {
                return is_FirstRowReport;
            }
            set
            {
                if (is_FirstRowReport != value)
                {
                    is_FirstRowReport = value;
                    AppDataAccess.SetMemvar("M_First_Row_D", is_FirstRowReport);
                }
            }
        }

        public static string FontName
        {
            get
            {
                return is_FontName;
            }
            set
            {
                if (is_FontName != value)
                {
                    is_FontName = value;
                    AppDataAccess.SetMemvar("M_Font", is_FontName);
                }
            }
        }

        public static float FontSize
        {
            get
            {
                return ii_FontSize;
            }
            set
            {
                if (ii_FontSize != value)
                {
                    ii_FontSize = value;
                    AppDataAccess.SetMemvar("M_FntSize", ii_FontSize.ToString());
                }
            }
        }

        public static string FullName
        {
            get
            {
                return is_FullName;
            }
            set
            {
                is_FullName = value;
            }
        }

        public static bool HistoryCtrl
        {
            get
            {
                return ib_HistoryCtrl;
            }
            set
            {
                if (ib_HistoryCtrl != value)
                {
                    ib_HistoryCtrl = value;
                    AppDataAccess.SetMemvar("M_Vou_History", ib_HistoryCtrl ? "1" : "0");
                }
            }
        }

        public static string InitMessage
        {
            get
            {
                return is_InitMessage;
            }
            set
            {
                if (is_InitMessage != value)
                {
                    is_InitMessage = value;
                    AppDataAccess.SetMemvar("M_IniVar", is_InitMessage);
                }
            }
        }

        private static AppSettings Instance
        {
            get
            {
                return AppSettings.Default;
            }
        }

        public static bool ItemFilter
        {
            get
            {
                return ib_ItemFilter;
            }
            set
            {
                if (ib_ItemFilter != value)
                {
                    ib_ItemFilter = value;
                    AppDataAccess.SetUservar(UserName, "Lookup_Vt", ib_ItemFilter ? "1" : "0");
                }
            }
        }

        public static int KeySaveAs
        {
            get
            {
                return ii_KeySaveAs;
            }
            set
            {
                if (ii_KeySaveAs != value)
                {
                    ii_KeySaveAs = value;
                    AppDataAccess.SetMemvar("M_KeySaveAs", ii_KeySaveAs.ToString());
                }
            }
        }

        public static int LCAmountDecimals
        {
            get
            {
                return ii_LCAmountDecimals;
            }
            set
            {
                if (ii_LCAmountDecimals != value)
                {
                    ii_LCAmountDecimals = value;
                    AppDataAccess.SetMemvar("LCAmountDecimals", ii_LCAmountDecimals.ToString());
                }
            }
        }

        public static int LCPriceDecimals
        {
            get
            {
                return ii_LCPriceDecimals;
            }
            set
            {
                if (ii_LCPriceDecimals != value)
                {
                    ii_LCPriceDecimals = value;
                    AppDataAccess.SetMemvar("LCPriceDecimals", ii_LCPriceDecimals.ToString());
                }
            }
        }

        public static bool LocationCtrl
        {
            get
            {
                return ib_LocationCtrl;
            }
            set
            {
                if (ib_LocationCtrl != value)
                {
                    ib_LocationCtrl = value;
                    AppDataAccess.SetMemvar("M_Ctrl_Location", ib_LocationCtrl ? "1" : "0");
                }
            }
        }

        public static bool LockAfterPrint
        {
            get
            {
                return ib_LockAfterPrint;
            }
            set
            {
                if (ib_LockAfterPrint != value)
                {
                    ib_LockAfterPrint = value;
                    AppDataAccess.SetMemvar("M_Lock_After_Print", ib_LockAfterPrint ? "1" : "0");
                }
            }
        }

        public static bool LockDefault
        {
            get
            {
                return ib_LockDefault;
            }
            set
            {
                if (ib_LockDefault != value)
                {
                    ib_LockDefault = value;
                    AppDataAccess.SetMemvar("M_Locked_Default", ib_LockDefault ? "1" : "0");
                }
            }
        }

        public static string LOGOPicturePath
        {
            get
            {
                return Instance.LOGOPicturePath;
            }
            set
            {
                Instance.LOGOPicturePath = value;
            }
        }

        public static bool LotNumberCtrl
        {
            get
            {
                return ib_LotNumberCtrl;
            }
            set
            {
                if (ib_LotNumberCtrl != value)
                {
                    ib_LotNumberCtrl = value;
                    AppDataAccess.SetMemvar("M_Ctrl_Lot_No", ib_LotNumberCtrl ? "1" : "0");
                }
            }
        }

        public static string NameOfEnterprise
        {
            get
            {
                return is_NameOfEnterprise;
            }
            set
            {
                is_NameOfEnterprise = value;
            }
        }

        public static string NameOfSubEnterprice
        {
            get
            {
                return is_NameOfSubEnterprice;
            }
            set
            {
                is_NameOfSubEnterprice = value;
            }
        }

        public static int NormQuantity
        {
            get
            {
                return ii_NormQuantity;
            }
            set
            {
                if (ii_NormQuantity != value)
                {
                    ii_NormQuantity = value;
                    AppDataAccess.SetUservar(UserName, "NormQuantity", ii_NormQuantity.ToString());
                }
            }
        }

        public static string NotValidChars
        {
            get
            {
                return is_NotValidChars;
            }
            set
            {
                if (is_NotValidChars != value)
                {
                    is_NotValidChars = value;
                    AppDataAccess.SetMemvar("M_Chr_Err", is_NotValidChars);
                }
            }
        }

        public static int NumberDigits
        {
            get
            {
                return ii_NumberDigits;
            }
            set
            {
                if (ii_NumberDigits != value)
                {
                    ii_NumberDigits = value;
                    AppDataAccess.SetMemvar("NumberDigits", ii_NumberDigits.ToString());
                }
            }
        }

        public static bool ObjectFilter
        {
            get
            {
                return ib_ObjectFilter;
            }
            set
            {
                if (ib_ObjectFilter != value)
                {
                    ib_ObjectFilter = value;
                    AppDataAccess.SetUservar(UserName, "Lookup_Dt", ib_ObjectFilter ? "1" : "0");
                }
            }
        }

        public static DateTime OpeningDateOfSubEnterprice
        {
            get
            {
                return id_OpeningDateOfSubEnterprice;
            }
            set
            {
                id_OpeningDateOfSubEnterprice = value;
            }
        }

        public static bool ParentCompany
        {
            get
            {
                return ib_ParentCompany;
            }
            set
            {
                ib_ParentCompany = value;
            }
        }

        public static string Password
        {
            get
            {
                return is_Password;
            }
            set
            {
                is_Password = value;
            }
        }

        public static string PaymentMethod
        {
            get
            {
                return is_PaymentMethod;
            }
            set
            {
                if (is_PaymentMethod != value)
                {
                    is_PaymentMethod = value;
                    AppDataAccess.SetUservar(UserName, "Payment_Method", is_PaymentMethod);
                }
            }
        }

        public static int PercentDecimals
        {
            get
            {
                return ii_PercentDecimals;
            }
            set
            {
                if (ii_PercentDecimals != value)
                {
                    ii_PercentDecimals = value;
                    AppDataAccess.SetMemvar("PercentDecimals", ii_PercentDecimals.ToString());
                }
            }
        }

        public static bool PostDefault
        {
            get
            {
                return ib_PostDefault;
            }
            set
            {
                if (ib_PostDefault != value)
                {
                    ib_PostDefault = value;
                    AppDataAccess.SetMemvar("M_Status_Default", ib_PostDefault ? "1" : "0");
                }
            }
        }

        public static string ProcessCode
        {
            get
            {
                return is_ProcessCode;
            }
            set
            {
                if (is_ProcessCode != value)
                {
                    is_ProcessCode = value;
                    AppDataAccess.SetUservar(UserName, "Ma_Sp_Default", is_ProcessCode);
                }
            }
        }

        public static string ProcMessage
        {
            get
            {
                return is_ProcMessage;
            }
            set
            {
                if (is_ProcMessage != value)
                {
                    is_ProcMessage = value;
                    AppDataAccess.SetMemvar("M_Process", is_ProcMessage);
                }
            }
        }

        public static bool QualityCtrl
        {
            get
            {
                ib_QualityCtrl = short.Parse(AppDataAccess.GetMemvar(1, "M_Ctrl_Quality_Item").ToString()) == 1;
                return ib_QualityCtrl;
            }
            set
            {
                if (ib_QualityCtrl != value)
                {
                    ib_QualityCtrl = value;
                    AppDataAccess.SetMemvar("M_Ctrl_Quality_Item", ib_QualityCtrl ? "1" : "0");
                }
            }
        }

        public static int QuantityDecimals
        {
            get
            {
                return ii_QuantityDecimals;
            }
            set
            {
                if (ii_QuantityDecimals != value)
                {
                    ii_QuantityDecimals = value;
                    AppDataAccess.SetUservar(UserName, "QuantityDecimals", ii_QuantityDecimals.ToString());
                }
            }
        }

        public static int RatioFormat
        {
            get
            {
                return ii_RatioFormat;
            }
            set
            {
                if (ii_RatioFormat != value)
                {
                    ii_RatioFormat = value;
                    AppDataAccess.SetUservar(UserName, "RatioFormat", ii_RatioFormat.ToString());
                }
            }
        }

        public static string SecondRowReport
        {
            get
            {
                return is_SecondRowReport;
            }
            set
            {
                if (is_SecondRowReport != value)
                {
                    is_SecondRowReport = value;
                    AppDataAccess.SetMemvar("M_Second_Row_D", is_SecondRowReport);
                }
            }
        }

        public static string ServerName
        {
            get
            {
                return Instance.ServerName;
            }
            set
            {
                Instance.ServerName = value;
            }
        }

        public static string ServerPassword
        {
            get
            {
                return Instance.ServerPassword;
            }
            set
            {
                Instance.ServerPassword = value;
            }
        }

        public static string ServerUserName
        {
            get
            {
                return Instance.ServerUserName;
            }
            set
            {
                Instance.ServerUserName = value;
            }
        }

        public static int ShowDateTime
        {
            get
            {
                return ii_ShowDateTime;
            }
            set
            {
                if (ii_ShowDateTime != value)
                {
                    ii_ShowDateTime = value;
                    AppDataAccess.SetMemvar("M_Show_DateTime", ii_ShowDateTime.ToString());
                }
            }
        }

        public static string SoftwareActiveCode
        {
            get
            {
                return Instance.SoftwareActiveCode;
            }
            set
            {
                Instance.SoftwareActiveCode = value;
            }
        }

        public static string SoftwareName
        {
            get
            {
                return is_SoftwareName;
            }
            set
            {
                is_SoftwareName = value;
            }
        }

        public static DateTime StartWorkingDate
        {
            get
            {
                return id_StartWorkingDate;
            }
            set
            {
                id_StartWorkingDate = value;
            }
        }

        public static int StockWarning
        {
            get
            {
                return ii_StockWarning;
            }
            set
            {
                if (ii_StockWarning != value)
                {
                    ii_StockWarning = value;
                    AppDataAccess.SetMemvar("M_Item_Warning", ii_StockWarning.ToString());
                }
            }
        }

        public static string Subsidiaries
        {
            get
            {
                return is_Subsidiaries;
            }
            set
            {
                is_Subsidiaries = value;
            }
        }

        public static string Subsidiary
        {
            get
            {
                return is_Subsidiary;
            }
            set
            {
                is_Subsidiary = value;
            }
        }

        public static Font SystemFont
        {
            get
            {
                if (!UserValiated)
                {
                    return new Font("Arial", 8.25f);
                }
                return new Font(FontName, FontSize);
            }
        }

        public static string TaxCodeOfSubEnterprice
        {
            get
            {
                return is_TaxCodeOfSubEnterprice;
            }
            set
            {
                is_TaxCodeOfSubEnterprice = value;
            }
        }

        public static string ThirdRowReport
        {
            get
            {
                return is_ThirdRowReport;
            }
            set
            {
                if (is_ThirdRowReport != value)
                {
                    is_ThirdRowReport = value;
                    AppDataAccess.SetMemvar("M_Third_Row_D", is_ThirdRowReport);
                }
            }
        }

        public static int UnCompMethod
        {
            get
            {
                return ii_UnCompMethod;
            }
            set
            {
                if (ii_UnCompMethod != value)
                {
                    ii_UnCompMethod = value;
                    AppDataAccess.SetMemvar("M_PP_DDSP", ii_UnCompMethod.ToString());
                }
            }
        }

        public static FormCalculator UserCalculator
        {
            get
            {
                if ((oCalculator == null) || oCalculator.ib_Disposed)
                {
                    oCalculator = new FormCalculator();
                }
                return oCalculator;
            }
        }

        public static string UserName
        {
            get
            {
                return is_UserName;
            }
            set
            {
                is_UserName = value;
            }
        }

        public static string UserReportPath
        {
            get
            {
                return (Application.StartupPath + @"\ReportFiles\" + QMVnSoft.Properties.Settings.Default.EnterpriseVersion.ToString() + @"\");
            }
        }

        public static int UserType
        {
            get
            {
                return ii_UserType;
            }
            set
            {
                ii_UserType = value;
            }
        }

        public static bool UserValiated
        {
            get
            {
                return ib_UserValiated;
            }
            set
            {
                ib_UserValiated = value;
            }
        }

        public static bool VATInPrice
        {
            get
            {
                return ib_VATInPrice;
            }
            set
            {
                if (ib_VATInPrice != value)
                {
                    ib_VATInPrice = value;
                    AppDataAccess.SetMemvar("M_Gia_Thue_Default", ib_VATInPrice ? "1" : "0");
                }
            }
        }

        public static decimal VATRange
        {
            get
            {
                return ii_VATRange;
            }
            set
            {
                if (ii_VATRange != value)
                {
                    ii_VATRange = value;
                    AppDataAccess.SetMemvar("M_Tron_VAT", ii_VATRange.ToString());
                }
            }
        }

        public static int WorkingYear
        {
            get
            {
                return ii_WorkingYear;
            }
            set
            {
                ii_WorkingYear = value;
            }
        }

        public enum TextControlLength
        {
            None,
            InvoiceCode,
            InvoiceNumber,
            ItemCode,
            ItemUnit,
            ItemDescription,
            InvoiceDescription
        }

        public enum TextControlTrimMode
        {
            None,
            Left,
            Right,
            All
        }

        public enum TextNumericFormat
        {
            None,
            Quantity,
            NormQuantity,
            RatioQuantity,
            LocalPrice,
            ForeignPrice,
            LocalAmount,
            ForeignAmount,
            Percent,
            ExchangeRate,
            IntNumber
        }
    }
}

